package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DzbqTagtemplates;
import com.ruoyi.system.service.IDzbqTagtemplatesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 模板信息Controller
 * 
 * @author tianxingxia
 * @date 2025-02-08
 */
@RestController
@RequestMapping("/system/tagtemplates")
public class DzbqTagtemplatesController extends BaseController
{
    @Autowired
    private IDzbqTagtemplatesService dzbqTagtemplatesService;

    /**
     * 查询模板信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:tagtemplates:list')")
    @GetMapping("/list")
    public TableDataInfo list(DzbqTagtemplates dzbqTagtemplates)
    {
        startPage();
        List<DzbqTagtemplates> list = dzbqTagtemplatesService.selectDzbqTagtemplatesList(dzbqTagtemplates);
        return getDataTable(list);
    }

    /**
     * 导出模板信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:tagtemplates:export')")
    @Log(title = "模板信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DzbqTagtemplates dzbqTagtemplates)
    {
        List<DzbqTagtemplates> list = dzbqTagtemplatesService.selectDzbqTagtemplatesList(dzbqTagtemplates);
        ExcelUtil<DzbqTagtemplates> util = new ExcelUtil<DzbqTagtemplates>(DzbqTagtemplates.class);
        util.exportExcel(response, list, "模板信息数据");
    }

    /**
     * 获取模板信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:tagtemplates:query')")
    @GetMapping(value = "/{templateId}")
    public AjaxResult getInfo(@PathVariable("templateId") Long templateId)
    {
        return success(dzbqTagtemplatesService.selectDzbqTagtemplatesByTemplateId(templateId));
    }

    /**
     * 新增模板信息
     */
    @PreAuthorize("@ss.hasPermi('system:tagtemplates:add')")
    @Log(title = "模板信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DzbqTagtemplates dzbqTagtemplates)
    {
        return toAjax(dzbqTagtemplatesService.insertDzbqTagtemplates(dzbqTagtemplates));
    }

    /**
     * 修改模板信息
     */
    @PreAuthorize("@ss.hasPermi('system:tagtemplates:edit')")
    @Log(title = "模板信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DzbqTagtemplates dzbqTagtemplates)
    {
        return toAjax(dzbqTagtemplatesService.updateDzbqTagtemplates(dzbqTagtemplates));
    }

    /**
     * 删除模板信息
     */
    @PreAuthorize("@ss.hasPermi('system:tagtemplates:remove')")
    @Log(title = "模板信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{templateIds}")
    public AjaxResult remove(@PathVariable Long[] templateIds)
    {
        return toAjax(dzbqTagtemplatesService.deleteDzbqTagtemplatesByTemplateIds(templateIds));
    }
}
